package menuBranch;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;

import javax.imageio.ImageIO;


// Project: 

/******************************************************************************
 * <p>
 * File: cropTileset.java
 * </p>
 * @author  Tadhg O'Sullivan, rogue
 * @author <a href="mailto:tadhg.osullivan@ucdconnect.ie">tadhg.osullivan@ucdconnect.ie</a>
 * @version 1.0, 2007
 * @created 20-Feb-07 6:06:06 PM
 * @revised 21-Feb-07
 * <p>
 * Description: takes in a tileSet buffered image and crops it into individual
 * tileObects and returns them in a LinkedList
 * </p>
 *****************************************************************************/

public class cropTileset {
	
	protected LinkedList<tileObject> ll;
	protected BufferedImage img = null;
	protected tileObject newTile;
	
	public LinkedList<tileObject> importTileset(){
		ll = new LinkedList<tileObject>();
		int count = 1;
		boolean collision = false;
		boolean goal = false;
		
		try {
			// get the tileset BufferedImage
		    img = ImageIO.read(new File("Tiles3.bmp"));
		} catch (IOException e) {
		}
		
		// for loop to crop the individual tiles and set their collisionState and goal booleans
		for(int i = 0; i < img.getWidth(); i += 8){
			if((count == 3) || (count == 8) || (count == 12) || (count == 18) || (count == 20) || (count == 21) || (count == 22)){
				collision  = false;
			}else{
				collision = true;
			}
			if((count == 12) || (count == 18) || (count == 20) || (count == 21) || (count == 22)){
				goal = true;
			}else{
				goal = false;
			}
			newTile = new tileObject(img.getSubimage(i, 0, 8, 8), count, collision, goal, 0, 0);
			//System.out.println( newTile.getGoal());
			//System.out.println(newTile.getImage().toString());
			//System.out.println(newTile.getCollisionState());
			//System.out.println(newTile.getNum());
			ll.add(newTile);
			count++;
		}
		return ll;
	}

}
